<%--
   departmentUser Selector
   Copyright (c) 2013 ISPERP
   Version : 1.0.0
 --%>
<%@ tag language="java" pageEncoding="UTF-8"
	trimDirectiveWhitespaces="true"%>


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>


<%@ attribute name="id" required="true" type="java.lang.String"
	description="唯一标识."%>

<%@ attribute name="name" type="java.lang.String" description="控件名称."%>

<%@ attribute name="idFieldName" required="false"
	type="java.lang.String" description="idFieldName。默认用户名：name"%>

<%@ attribute name="valueControlId" required="true"
	type="java.lang.String" description="值所保存的空间的Id。"%>

<%@ attribute name="displayValue" required="true"
	type="java.lang.String" description="默认显示的值。"%>

<%@ attribute name="cusDialogWidth" required="false"
	type="java.lang.Integer" description="对话框宽度，默认540"%>

<%@ attribute name="cusDialogHeight" required="false"
	type="java.lang.Integer" description="对话框高度。默认420"%>

<%@ attribute name="displayValueCssClass" required="false"
	type="java.lang.String" description="displayValueCss样式名"%>

<%@ attribute name="displayValueStyle" required="false"
	type="java.lang.String" description="displayValueStyle样式"%>

<%@ attribute name="afterSelected" required="false"
	type="java.lang.String" description="afterSelected"%>
<%@ attribute name="multiselect" required="false"
	type="java.lang.Boolean" description="afterSelected"%>

<%@ attribute name="roleNames" required="false" type="java.lang.String"
	description="角色"%>

<%@ attribute name="ifIncludeNoRoleUser" required="false"
	type="java.lang.String" description="是否包含角色的用户"%>

<%@ attribute name="parentIdControlId" required="false"
	type="java.lang.String" description="parentIdControlId"%>

<c:if test="${empty cusDialogWidth}">
	<c:set var="cusDialogWidth" value="560" scope="request" />
</c:if>
<c:if test="${empty ifIncludeNoRoleUser}">
	<c:set var="ifIncludeNoRoleUser" value="false" scope="request" />
</c:if>
<c:if test="${empty cusDialogHeight}">
	<c:set var="cusDialogHeight" value="445" scope="request" />
</c:if>
<c:if test="${empty parentIdControlId}">
	<c:set var="parentIdControlId" value="" scope="request" />
</c:if>

<script type="text/javascript">
function ${id}Tree_onNodeClick(event, treeId, treeNode) {
	${id}Grid.search({
		"field" : "department_treenode_path",
		"op" : "bw",
		"data" : treeNode.treenodePath
	});
}
</script>
<input id="${id}" name="${name}" type="text" value="${displayValue }"
	style="${displayValueStyle}"
	class="selector-input ${displayValueCssClass}" readonly="readonly"
	onclick="$(this).addClass('selector-hover'); $('#${id}Dialog').wijdialog('open');">
<a id="${id}Selector" class="icon icon-search"
	onclick="$('#${id}Dialog').wijdialog('open');"
	style="display: none;padding:1px 0px" href="javascript:void(0);"><span
	style="display: inline-block;text-indent:-999em;width:16px;height:16px">选择</span>
</a>
<div id="${id}Dialog" title="请选择"
	style="display:none;overflow: hidden;padding:0"></div>
<jsp:doBody />
<script type="text/javascript">
	
$(document).ready(function(){
	isperp.openDialog({
		id:"${id}Dialog",
		contentUrl:'tags/selector/ciTreeSelector?roleName=${roleNames}&ifIncludeNoRoleUser=${ifIncludeNoRoleUser}&parentIdControlId=${parentIdControlId}&ctId=${id}&dheight=${cusDialogHeight}&idFieldName=${idFieldName }&multiselect=${multiselect}',
		onThisWindow : true,
		title:"选择",
		width : ${cusDialogWidth},
		height : ${cusDialogHeight},
		modal : false,
		autoOpen : false,
		resizable:false,
		beforeClose: function( event, ui ) {$("#${id}").removeClass("selector-hover");},
		buttons:[{
			 text:"确定",
			 "class":'nui-mainbtn',
			 click:function(){
				var row=$("#${id}Dialog").find("iframe")[0].contentWindow.getSelectedValue();
				${id}SetSelected(row); }
		  },{
	          text: "关闭",
	          "class": 'grey',
	          click: function() {
	               $(this).wijdialog("close");
	          }
	      }]
	});
});
function ${id}SetSelected(row){
	if(!row[0]){
		isperp.alert("请选择一条数据！");
		return false;
	}
	$("#${valueControlId}").val(row[0]);
	$("#${id}").val(row[1]);
	${afterSelected}
	$("#${id}Dialog").wijdialog("close");
}
</script>




